package com.laboratory.report.lab04.lab0401;

import lombok.Builder;
import lombok.Data;

/**
 * 奖牌
 */
@Builder
@Data
public class Medal {

    private String queueName;
    private int gold;
    private int sivler;
    private int copper;
    private int total;

    public static Medal fromLine(String line) {
        if(null == line || line.isEmpty()) {
            return null;
        }
        String[] lineArr = line.split("，");
        Medal medal = Medal.builder()
                .queueName(lineArr[0])
                .gold(Integer.parseInt(lineArr[1]))
                .sivler(Integer.parseInt(lineArr[2]))
                .copper(Integer.parseInt(lineArr[3]))
                .total(Integer.parseInt(lineArr[4]))
                .build();
        return medal;
    }

    public String toLine() {
        return new StringBuilder().append(getQueueName()).append("，")
                .append(getGold()).append("，")
                .append(getSivler()).append("，")
                .append(getCopper()).append("，")
                .append(getTotal())
                .toString();
    }
}
